package com.study.springboot.SpringBoot_A.mq.rabbitmq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author 赵超
 * @Description 生产者
 * @create 2018-03-28 14:36
 **/
@Component
public class HelloSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send() {
        String con = "hello, " + new Date();
        System.out.println("Send: " + con);
        amqpTemplate.convertAndSend("hello", con);
    }

    public void sendObj(Object o) {
//        String time = "hello, " + new Date();
//        System.out.println("Send: " + time + " " + o);
        amqpTemplate.convertAndSend("hello", o + "   __  1");
    }

}
